// Refer to document: https://github.com/nacos-group/nacos-examples/tree/master/nacos-spring-boot-example/nacos-spring-boot-config-example
package com.example.user.controller;

import com.example.user.entity.User;
import com.example.user.service.UserService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

import java.util.List;

import static org.springframework.web.bind.annotation.RequestMethod.GET;

/**
 * @author mtl
 */
@Controller
@RequestMapping("/smart-auth-server")
public class ConfigController {

    @Value("${server:port}")
    private String useLocalCache;

    @Resource
    UserService userService;

    public void setUseLocalCache(String useLocalCache) {
        this.useLocalCache = useLocalCache;
    }

    @RequestMapping(value = "/get", method = GET)
    @ResponseBody
    public String get() {
        return useLocalCache;
    }


    @GetMapping(value = "/userList")
    @ResponseBody
    public List<User> userList() {
        return userService.list();
    }


    @GetMapping(value = "/batchList")
    public String batchList(Integer size,Integer page){
        return userService.batchList(size, page);
    }
}